package cn.edu.hstc.wm.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import cn.edu.hstc.wm.AppApplication;
import cn.edu.hstc.wm.R;
import cn.edu.hstc.wm.bean.User;
import cn.edu.hstc.wm.ui.base.BaseFragment;

public class MyInfo extends BaseFragment {

	private View mRootView;
	private User mUser;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		mRootView = inflater.inflate(R.layout.my_info, null);
		AppApplication app = (AppApplication) getActivity().getApplication();
		mUser = app.getLoginUser();
		
		initView();
		return mRootView;
	}
	
	private void initView(){
		TextView name = (TextView) mRootView.findViewById(R.id.tv_my_info_name);
		ImageView genderImageView = (ImageView) mRootView.findViewById(R.id.iv_my_info_gender);
		ImageView headIcon =  (ImageView) mRootView.findViewById(R.id.iv_my_info_head);
		
		TextView registerTimeTextView=  (TextView) mRootView.findViewById(R.id.tv_my_info_register_time);
		TextView lastTime = (TextView) mRootView.findViewById(R.id.tv_my_info_last_time);
		
		
		name.setText(mUser.getName());
		genderImageView.setImageResource(Integer.parseInt(mUser.getGender())==1?R.drawable.ic_gender_gentleman:R.drawable.ic_gender_lady);
		headIcon.setImageResource(R.drawable.ic_default_head);
		registerTimeTextView.setText(String.format(getString(R.string.myinfo_register_time),mUser.getJointime()));
		lastTime.setText(String.format(getString(R.string.myinfo_last_time), mUser.getLatestonline()));
	}

}
